package array;

public class Solution_121 {
    public int maxProfit(int[] prices) {
        int minPrice = prices[0], res = 0;
        for (int price : prices) {
            res=Math.max(res,price-minPrice);
            minPrice=Math.min(minPrice,price);
        }
        return res;
    }
}
